﻿using System;
using System.Data;
using System.Collections.Generic;
using Chenxin.Lib.Business.Entity;
namespace Chenxin.Lib.Business.BLL
{
    /// <summary>
    /// 业务逻辑类t_Business_Record_BaseInfo 的摘要说明。
    /// </summary>
    public class ContractArchive
    {
        public ContractArchive()
        { }
        #region  成员方法
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public void Add(Chenxin.Lib.Business.Entity.t_Business_Record_BaseInfo model)
        {
            Chenxin.Lib.Business.DAL.t_Business_Record_BaseInfo.Add(model);
        }

        /// <summary>
        /// 更新一条数据
        /// </summary>
        public void Update(Chenxin.Lib.Business.Entity.t_Business_Record_BaseInfo model)
        {
            Chenxin.Lib.Business.DAL.t_Business_Record_BaseInfo.Update(model);
        }

        /// <summary>
        /// 删除一条数据
        /// </summary>
        public void Delete(Guid RecordId)
        {

            Chenxin.Lib.Business.DAL.t_Business_Record_BaseInfo.Delete(RecordId);
        }

        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Chenxin.Lib.Business.Entity.t_Business_Record_BaseInfo GetModel(Guid RecordId)
        {

            return Chenxin.Lib.Business.DAL.t_Business_Record_BaseInfo.GetModel(RecordId);
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public DataSet GetList(string strWhere)
        {
            return Chenxin.Lib.Business.DAL.t_Business_Record_BaseInfo.GetList(strWhere);
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List<Chenxin.Lib.Business.Entity.t_Business_Record_BaseInfo> GetModelList(string strWhere)
        {
            DataSet ds = Chenxin.Lib.Business.DAL.t_Business_Record_BaseInfo.GetList(strWhere);
            return DataTableToList(ds.Tables[0]);
        }
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List<Chenxin.Lib.Business.Entity.t_Business_Record_BaseInfo> DataTableToList(DataTable dt)
        {
            List<Chenxin.Lib.Business.Entity.t_Business_Record_BaseInfo> modelList = new List<Chenxin.Lib.Business.Entity.t_Business_Record_BaseInfo>();
            int rowsCount = dt.Rows.Count;
            if (rowsCount > 0)
            {
                Chenxin.Lib.Business.Entity.t_Business_Record_BaseInfo model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new Chenxin.Lib.Business.Entity.t_Business_Record_BaseInfo();
                    if (dt.Rows[n]["RecordId"].ToString() != "")
                    {
                        model.RecordId = new Guid(dt.Rows[n]["RecordId"].ToString());
                    }
                    if (dt.Rows[n]["HouseId"].ToString() != "")
                    {
                        model.HouseId = new Guid(dt.Rows[n]["HouseId"].ToString());
                    }
                    model.HouseCode = dt.Rows[n]["HouseCode"].ToString();
                    model.HouseAddress = dt.Rows[n]["HouseAddress"].ToString();
                    model.PropertyCode = dt.Rows[n]["PropertyCode"].ToString();
                    if (dt.Rows[n]["BuildingArea"].ToString() != "")
                    {
                        model.BuildingArea = decimal.Parse(dt.Rows[n]["BuildingArea"].ToString());
                    }
                    model.CompleteYear = dt.Rows[n]["CompleteYear"].ToString();
                    if (dt.Rows[n]["Total_Floor"].ToString() != "")
                    {
                        model.Total_Floor = int.Parse(dt.Rows[n]["Total_Floor"].ToString());
                    }
                    if (dt.Rows[n]["Cur_Floor"].ToString() != "")
                    {
                        model.Cur_Floor = int.Parse(dt.Rows[n]["Cur_Floor"].ToString());
                    }
                    model.BuildingType = dt.Rows[n]["BuildingType"].ToString();
                    model.HouseUse = dt.Rows[n]["HouseUse"].ToString();
                    if (dt.Rows[n]["BelongUserCityId"].ToString() != "")
                    {
                        model.BelongUserCityId = new Guid(dt.Rows[n]["BelongUserCityId"].ToString());
                    }
                    model.BelongUserCityName = dt.Rows[n]["BelongUserCityName"].ToString();
                    if (dt.Rows[n]["BelongUserCompanyId"].ToString() != "")
                    {
                        model.BelongUserCompanyId = new Guid(dt.Rows[n]["BelongUserCompanyId"].ToString());
                    }
                    model.BelongUserCompanyName = dt.Rows[n]["BelongUserCompanyName"].ToString();
                    if (dt.Rows[n]["BelongUserDepartmentId"].ToString() != "")
                    {
                        model.BelongUserDepartmentId = new Guid(dt.Rows[n]["BelongUserDepartmentId"].ToString());
                    }
                    model.BelongUserDepartmentName = dt.Rows[n]["BelongUserDepartmentName"].ToString();
                    if (dt.Rows[n]["BelongUserId"].ToString() != "")
                    {
                        model.BelongUserId = new Guid(dt.Rows[n]["BelongUserId"].ToString());
                    }
                    model.BelongUserName = dt.Rows[n]["BelongUserName"].ToString();
                    if (dt.Rows[n]["CityId"].ToString() != "")
                    {
                        model.CityId = new Guid(dt.Rows[n]["CityId"].ToString());
                    }
                    model.CityName = dt.Rows[n]["CityName"].ToString();
                    if (dt.Rows[n]["CompanyId"].ToString() != "")
                    {
                        model.CompanyId = new Guid(dt.Rows[n]["CompanyId"].ToString());
                    }
                    model.CompanyName = dt.Rows[n]["CompanyName"].ToString();
                    if (dt.Rows[n]["DepartId"].ToString() != "")
                    {
                        model.DepartId = new Guid(dt.Rows[n]["DepartId"].ToString());
                    }
                    model.DepartName = dt.Rows[n]["DepartName"].ToString();
                    if (dt.Rows[n]["EmployeeId"].ToString() != "")
                    {
                        model.EmployeeId = new Guid(dt.Rows[n]["EmployeeId"].ToString());
                    }
                    model.Employee = dt.Rows[n]["Employee"].ToString();
                    model.LoanInfo = dt.Rows[n]["LoanInfo"].ToString();
                    if (dt.Rows[n]["BargainTime"].ToString() != "")
                    {
                        model.BargainTime = DateTime.Parse(dt.Rows[n]["BargainTime"].ToString());
                    }
                    if (dt.Rows[n]["LoanTime"].ToString() != "")
                    {
                        model.LoanTime = DateTime.Parse(dt.Rows[n]["LoanTime"].ToString());
                    }
                    model.BargainType = dt.Rows[n]["BargainType"].ToString();
                    if (dt.Rows[n]["WorkCityId"].ToString() != "")
                    {
                        model.WorkCityId = new Guid(dt.Rows[n]["WorkCityId"].ToString());
                    }
                    model.WorkCityName = dt.Rows[n]["WorkCityName"].ToString();
                    if (dt.Rows[n]["WorkCompanyId"].ToString() != "")
                    {
                        model.WorkCompanyId = new Guid(dt.Rows[n]["WorkCompanyId"].ToString());
                    }
                    model.WorkCompanyName = dt.Rows[n]["WorkCompanyName"].ToString();
                    if (dt.Rows[n]["WorkDepartId"].ToString() != "")
                    {
                        model.WorkDepartId = new Guid(dt.Rows[n]["WorkDepartId"].ToString());
                    }
                    model.WorkDepartName = dt.Rows[n]["WorkDepartName"].ToString();
                    if (dt.Rows[n]["WorkPersonId"].ToString() != "")
                    {
                        model.WorkPersonId = new Guid(dt.Rows[n]["WorkPersonId"].ToString());
                    }
                    model.WorkPersonName = dt.Rows[n]["WorkPersonName"].ToString();
                    if (dt.Rows[n]["BargainCityId"].ToString() != "")
                    {
                        model.BargainCityId = new Guid(dt.Rows[n]["BargainCityId"].ToString());
                    }
                    model.BargainCityName = dt.Rows[n]["BargainCityName"].ToString();
                    if (dt.Rows[n]["BargainCompanyId"].ToString() != "")
                    {
                        model.BargainCompanyId = new Guid(dt.Rows[n]["BargainCompanyId"].ToString());
                    }
                    model.BargainCompanyName = dt.Rows[n]["BargainCompanyName"].ToString();
                    model.Mobile = dt.Rows[n]["Mobile"].ToString();
                    model.SpecialInfo = dt.Rows[n]["SpecialInfo"].ToString();
                    if (dt.Rows[n]["TotalPrice"].ToString() != "")
                    {
                        model.TotalPrice = decimal.Parse(dt.Rows[n]["TotalPrice"].ToString());
                    }
                    model.Unit = dt.Rows[n]["Unit"].ToString();
                    if (dt.Rows[n]["FitPrice"].ToString() != "")
                    {
                        model.FitPrice = decimal.Parse(dt.Rows[n]["FitPrice"].ToString());
                    }
                    model.MortgageInfo = dt.Rows[n]["MortgageInfo"].ToString();
                    model.FariInfo = dt.Rows[n]["FariInfo"].ToString();
                    model.PayLoanDay = dt.Rows[n]["PayLoanDay"].ToString();
                    model.PayMode = dt.Rows[n]["PayMode"].ToString();
                    model.RepairFund = dt.Rows[n]["RepairFund"].ToString();
                    model.GiveHouseTime =dt.Rows[n]["GiveHouseTime"].ToString();
              
                    model.Remark = dt.Rows[n]["Remark"].ToString();
                    model.FairPoint = dt.Rows[n]["FairPoint"].ToString();
                    model.LoanAnswerContent = dt.Rows[n]["LoanAnswerContent"].ToString();
                    if (dt.Rows[n]["LoanIsAnswer"].ToString() != "")
                    {
                        if ((dt.Rows[n]["LoanIsAnswer"].ToString() == "1") || (dt.Rows[n]["LoanIsAnswer"].ToString().ToLower() == "true"))
                        {
                            model.LoanIsAnswer = true;
                        }
                        else
                        {
                            model.LoanIsAnswer = false;
                        }
                    }
                    model.LawAnswerContent = dt.Rows[n]["LawAnswerContent"].ToString();
                    if (dt.Rows[n]["LawIsAnswer"].ToString() != "")
                    {
                        if ((dt.Rows[n]["LawIsAnswer"].ToString() == "1") || (dt.Rows[n]["LawIsAnswer"].ToString().ToLower() == "true"))
                        {
                            model.LawIsAnswer = true;
                        }
                        else
                        {
                            model.LawIsAnswer = false;
                        }
                    }
                    if (dt.Rows[n]["AnswersNum"].ToString() != "")
                    {
                        model.AnswersNum = int.Parse(dt.Rows[n]["AnswersNum"].ToString());
                    }
                    if (dt.Rows[n]["IsAnswer"].ToString() != "")
                    {
                        if ((dt.Rows[n]["IsAnswer"].ToString() == "1") || (dt.Rows[n]["IsAnswer"].ToString().ToLower() == "true"))
                        {
                            model.IsAnswer = true;
                        }
                        else
                        {
                            model.IsAnswer = false;
                        }
                    }
                    if (dt.Rows[n]["Status"].ToString() != "")
                    {
                        model.Status = int.Parse(dt.Rows[n]["Status"].ToString());
                    }
                    if (dt.Rows[n]["CreateCityId"].ToString() != "")
                    {
                        model.CreateCityId = new Guid(dt.Rows[n]["CreateCityId"].ToString());
                    }
                    model.CreateCityName = dt.Rows[n]["CreateCityName"].ToString();
                    if (dt.Rows[n]["CreateCompanyId"].ToString() != "")
                    {
                        model.CreateCompanyId = new Guid(dt.Rows[n]["CreateCompanyId"].ToString());
                    }
                    model.CreateCompanyName = dt.Rows[n]["CreateCompanyName"].ToString();
                    if (dt.Rows[n]["CreateDepartmentId"].ToString() != "")
                    {
                        model.CreateDepartmentId = new Guid(dt.Rows[n]["CreateDepartmentId"].ToString());
                    }
                    model.CreateDepartmentName = dt.Rows[n]["CreateDepartmentName"].ToString();
                    if (dt.Rows[n]["CreateUserId"].ToString() != "")
                    {
                        model.CreateUserId = new Guid(dt.Rows[n]["CreateUserId"].ToString());
                    }
                    model.CreateUserName = dt.Rows[n]["CreateUserName"].ToString();
                    if (dt.Rows[n]["CreateTime"].ToString() != "")
                    {
                        model.CreateTime = DateTime.Parse(dt.Rows[n]["CreateTime"].ToString());
                    }
                    if (dt.Rows[n]["UpdateCityId"].ToString() != "")
                    {
                        model.UpdateCityId = new Guid(dt.Rows[n]["UpdateCityId"].ToString());
                    }
                    model.UpdateCityName = dt.Rows[n]["UpdateCityName"].ToString();
                    if (dt.Rows[n]["UpdateCompanyId"].ToString() != "")
                    {
                        model.UpdateCompanyId = new Guid(dt.Rows[n]["UpdateCompanyId"].ToString());
                    }
                    model.UpdateCompanyName = dt.Rows[n]["UpdateCompanyName"].ToString();
                    if (dt.Rows[n]["UpdateDepartmentId"].ToString() != "")
                    {
                        model.UpdateDepartmentId = new Guid(dt.Rows[n]["UpdateDepartmentId"].ToString());
                    }
                    model.UpdateDepartmentName = dt.Rows[n]["UpdateDepartmentName"].ToString();
                    if (dt.Rows[n]["UpdateUserId"].ToString() != "")
                    {
                        model.UpdateUserId = new Guid(dt.Rows[n]["UpdateUserId"].ToString());
                    }
                    model.UpdateUserName = dt.Rows[n]["UpdateUserName"].ToString();
                    if (dt.Rows[n]["UpdateTime"].ToString() != "")
                    {
                        model.UpdateTime = DateTime.Parse(dt.Rows[n]["UpdateTime"].ToString());
                    }
                    model.VenderTel = dt.Rows[n]["VenderTel"].ToString();
                    model.VenderAddress = dt.Rows[n]["VenderAddress"].ToString();
                    model.BuyerAddress = dt.Rows[n]["BuyerAddress"].ToString();
                    model.BuyerTel = dt.Rows[n]["BuyerTel"].ToString();
                    if (dt.Rows[n]["EvaluatePrice"].ToString() != "")
                    {
                        model.EvaluatePrice = decimal.Parse(dt.Rows[n]["EvaluatePrice"].ToString());
                    }
                    model.LonggevityLevel = dt.Rows[n]["LonggevityLevel"].ToString();
                    model.LoanBank = dt.Rows[n]["LoanBank"].ToString();
                    model.EvaluateCompany = dt.Rows[n]["EvaluateCompany"].ToString();
                    if (dt.Rows[n]["FundLoanPrice"].ToString() != "")
                    {
                        model.FundLoanPrice = decimal.Parse(dt.Rows[n]["FundLoanPrice"].ToString());
                    }
                    model.FundLoanEndYear = dt.Rows[n]["FundLoanEndYear"].ToString();
                    if (dt.Rows[n]["BusinessLoanPrice"].ToString() != "")
                    {
                        model.BusinessLoanPrice = decimal.Parse(dt.Rows[n]["BusinessLoanPrice"].ToString());
                    }
                    model.BusinessLoanEndYear = dt.Rows[n]["BusinessLoanEndYear"].ToString();
                    model.Prejudication = dt.Rows[n]["Prejudication"].ToString();
                    if (dt.Rows[n]["TransferDate"].ToString() != "")
                    {
                        model.TransferDate = DateTime.Parse(dt.Rows[n]["TransferDate"].ToString());
                    }
                    modelList.Add(model);
                }
            }
            return modelList;
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public DataSet GetAllList()
        {
            return GetList("");
        }

        #endregion  成员方法
    }
}

